#include "dialogconfirmsale.h"
#include "ui_dialogconfirmsale.h"

DialogConfirmSale::DialogConfirmSale(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DialogConfirmSale)
{
    ui->setupUi(this);
    ui->dbAmountReceived->selectAll ();
}

DialogConfirmSale::~DialogConfirmSale()
{
    delete ui;
}

void DialogConfirmSale::setAmountDue(double amount)
{
    ui->dbAmountDue->setValue (amount);
}

void DialogConfirmSale::on_cbSaleConfirmed_clicked()
{
    accept ();
}

void DialogConfirmSale::on_cbReturnToSale_clicked()
{
    reject ();
}

void DialogConfirmSale::on_dbAmountReceived_valueChanged(double /*arg1*/)
{
    ui->dbAmountReturn->setValue (ui->dbAmountReceived->value ()-ui->dbAmountDue->value ());
}

void DialogConfirmSale::on_dbAmountDue_valueChanged(double /*arg1*/)
{
     ui->dbAmountReturn->setValue (ui->dbAmountReceived->value ()-ui->dbAmountDue->value ());
}
